#ifndef __I386_KERNEL_IRQ_H__
#define __I386_KERNEL_IRQ_H__

#include "common/basictypes.h"
#include "common/linkage.h"
#include "linux/irq_vector.h"
#include "i386/kernel/ptrace.h" // pt_regs

#define IRQ_INPROGRESS    1
#define IRQ_DISABLED      2
#define IRQ_PENDING       4
#define IRQ_REPLAY        8
#define IRQ_AUTODETECT    16
#define IRQ_WAITING       32
#define IRQ_LEVEL         64
#define IRQ_MASKED        128
#define IRQ_PER_CPU       256

struct hw_interrupt_type {
  const char* typename;
  u32 (*startup)(u32 irq);
  void (*shutdown)(u32 irq);
  void (*enable)(u32 irq);
  void (*disable)(u32 irq);
  void (*ack)(u32 irq);
  void (*end)(u32 irq);
  // void (*set_affinity)(u32 flags, cpumask_t dest);
};
extern struct hw_interrupt_type no_irq_type;

typedef struct irq_desc {
  struct hw_interrupt_type *handler;
  void *handler_data;
  struct irqaction *action;
  u32 status;
  u32 depth;
  u32 irq_count;
  u32 irqs_unhandled;
} /*____cacheline_align*/ irq_desc_t;

extern irq_desc_t irq_desc[NR_IRQS];

/* 文件 linux/irq/manage.c */
asmlinkage int setup_irq(u32 irq, struct irqaction* new);

asmlinkage u32 __do_IRQ(u32 irq, struct pt_regs * regs);

/*
 * 初始化 /proc 当中与中断系统相关的文件
 */
void init_irq_proc(void);

#endif  // __I386_KERNEL_IRQ_H__
